﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp4
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }


        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string UserName = textBox3.Text;
            string PassWord = textBox1.Text;
            string RePassWord = textBox2.Text;

            if (textBox3.Text == null)
            {
                MessageBox.Show("注册信息不能为空", "提示");
            }

            else
            {
                string connect = "server=.;database=Blogs;uid=hzh;pwd=hzh2000623;";
                SqlConnection sqlConnection = new SqlConnection(connect);
                sqlConnection.Open();
                
                string sqlOrder = string.Format("insert into Users(UserName,PassWord) values ('{0}','{1}')", UserName, PassWord);
                SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlOrder, sqlConnection);
                DataTable dt = new DataTable();

                dataAdapter.Fill(dt);

                MessageBox.Show("注册成功！","提示");
                this.Close();
            }
           
        }


        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
